﻿using System;

class MostFrequentNumber
{
    static void Main()
    {
        int[] array = { 4, 4, 55, 6, -1, 2345, 1, 1, 55, 1, 55, 17, -3, 55 };

        Array.Sort(array);

        int maxCount = 1;
        int length = 1;
        int mostFrequentElement = array[0];
        int element = mostFrequentElement;

        for (int i = 1; i < array.Length; i++)
        {
            if (array[i] == element)
            {
                length++;
            }
            else
            {
                if (length > maxCount)
                {
                    maxCount = length;
                    mostFrequentElement = element;
                }

                length = 1;
                element = array[i];
            }
        }

        Console.WriteLine("The most frequent element is: [{0}] --> ({1} times)", mostFrequentElement, maxCount);
    }
}
